home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / displytl / pm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  3.5 KB  |  126 lines

  1. /* include file defining constants/macros for PM files.  Used by xvpm.c 
  2.  */
  3.  
  4. /*
  5.  * Copyright 1989, 1990 by the University of Pennsylvania
  6.  *
  7.  * Permission to use, copy, and distribute for non-commercial purposes,
  8.  * is hereby granted without fee, providing that the above copyright
  9.  * notice appear in all copies and that both the copyright notice and this
  10.  * permission notice appear in supporting documentation.
  11.  *
  12.  * The software may be modified for your own purposes, but modified versions
  13.  * may not be distributed.
  14.  *
  15.  * This software is provided "as is" without any express or implied warranty.
  16.  */
  17. /* $Header $ */
  18. /* $Log $ */
  19. #define    PM_MAGICNO    0x56494557        /* Hex for VIEW */
  20. #define PM_MAXNELM    1024
  21. #define PM_MAXNBAND    1024
  22. #define PM_NOSHIFT    0
  23. #define PM_SHIFT    1
  24.  
  25. #define    PM_A        0x8000
  26. #define    PM_C        0x8001
  27. #define    PM_S        0x8002
  28. #define    PM_I        0x8004
  29. #define PM_F        0xc004
  30.  
  31. #define PM_RED 0xff
  32. #define PM_GREEN 0xff00
  33. #define PM_BLUE 0xff0000
  34. #define PM_ALPHA 0xff000000
  35. #define PM_BW 0
  36.  
  37. #define    PM_CMAX        0xff
  38. #define PM_SMAX        0x7fff
  39. #define    PM_IMAX        0x7fffffff
  40. #define PM_FMAX        1.7E38
  41.  
  42. #define PM_IOHDR_SIZE    (sizeof(pmpic)-(2*sizeof(char*)))
  43.  
  44. #define    pm_max(pm)    ((pm)->pm_form == PM_C ? PM_CMAX :          \
  45.                 (pm)->pm_form == PM_S ? PM_SMAX :      \
  46.                     (pm)->pm_form == PM_I ? PM_IMAX : \
  47.                          PM_FMAX)
  48.  
  49. #define pm_index(fm)    (((fm)&0xff)-(((fm)>>14)&01))
  50. #define    pm_sel(fm,fn)    (*((fn)[pm_index(fm)]))
  51. #define pm_iindex(a,nc,cr,cc)    ((a)+((cr)*(nc))+(cc))
  52.  
  53. #define pm_nelm(p)    ((p)->pm_ncol * (p)->pm_nrow)
  54. #define pm_nbelm(p)    (pm_nelm(p) * (p)->pm_nband)
  55. #define pm_psize(p)    (pm_nbelm(p) * (((p)->pm_form)&0xff))
  56. #define pm_isize(p)    ((p)->pm_np * pm_psize(p))
  57. #define pm_npix(p)      (pm_nbelm(p) * (p)->pm_np)
  58.  
  59. #include <sys/types.h>
  60.  
  61. typedef struct {
  62.     int    pm_id;        /* Magic number for pm format files.    */
  63.     int    pm_np;        /* Number of planes. Normally 1.    */
  64.     int    pm_nrow;    /* Number of rows. 1 - MAXNELM.        */
  65.     int    pm_ncol;    /* Number of columns. 1 - MAXNELM.    */
  66.     int    pm_nband;    /* Number of bands.            */
  67.     int    pm_form;    /* Pixel format.            */
  68.     int    pm_cmtsize;    /* Number comment bytes. Includes NULL. */
  69.     char    *pm_image;    /* The image itself.            */
  70.     char    *pm_cmt;    /* Transforms performed.        */
  71. } pmpic;
  72.  
  73. typedef    struct {
  74.     int    pm_x;        /* X Position. */
  75.     int    pm_y;        /* Y Position. */
  76.     int    pm_z;        /* Z Position. */
  77.     float    pm_ux;        /* Uncertainty in x. */
  78.     float    pm_uy;        /* Uncertainty in y. */
  79.     float    pm_uz;        /* Uncertainty in z. */
  80. } pmxyz;
  81.  
  82. #define    PM_EBASE    100
  83. #define PM_EMALLOC    101
  84. #define PM_EBADPARAM    102
  85. #define PM_EBADPIC    103
  86. #define PM_EBADFORM    104
  87. #define PM_EBADMAGIC    105
  88. #define PM_ENULLPIC    106    /* picture given was NULL */
  89. #define PM_EBADPLANES   107  /* invalid # of planes chosen for format */
  90. #define PM_EBADBANDS     108 /* invalid # of bands chosen for format */
  91. #define PM_EBADSIZE     109 /* # of rows/cols and x offsets, y offsets
  92.                too big for ikonas */
  93. #define PM_EBADCOLORS     110 /* invalid number of colors chosen for format */
  94. #define PM_EBADCOLORPLANE 111 /* invalid color plane entered */
  95.  
  96.  
  97. #define PM_NERROR    12
  98. #define PM_ERROR(e)    (((e) < PM_EBASE || (e) > (PM_EBASE + PM_NERROR)) ? \
  99.                 0 : (e) - PM_EBASE)
  100. extern char    *pm_errmsg[];
  101.  
  102. pmpic    *pm_add();
  103. pmpic    *pm_addcmt();
  104. pmpic    *pm_alloc();
  105. pmpic    *pm_and();
  106. pmpic    *pm_bthresh();
  107. pmpic    *pm_cast();
  108. char    *pm_cmt();
  109. pmpic    *pm_conv();
  110. pmpic    *pm_ebadform();
  111. int    pm_getcmt();
  112. pmpic    *pm_ikrd();
  113. pmpic    *pm_ikwr();
  114. pmpic    *pm_neg();
  115. pmpic    *pm_or();
  116. pmpic    *pm_prep();
  117. pmpic    *pm_rdhdr();
  118. pmpic    *pm_read();
  119. pmpic    *pm_scale();
  120. pmpic    *pm_sub();
  121. pmpic    *pm_thresh();
  122. pmpic    *pm_write();
  123.  
  124. pmxyz    *pm_centroid();
  125.  
  126.